
	var craft_group = 1;
	var science_group = 2;
	var art_group = 4;
	var civic_group = 8;
	var religion_group = 16;

	
	var pottery = "c0";
	var clothmaking = "c1";
	var metalworking = "c2";
	var agriculture = "c3";
	var roadbuilding = "c4";
	var mining = "c5";
	var engineering = "c6";
	var astronomy = "c7";
	var coinage = "c8";
	var medicine = "c9";
	var mathematics = "c10";
	var dramaetpoetry = "c11";
	var music = "c12";
	var architecture = "c13";
	var literacy = "c14";
	var law = "c15";
	var democracy = "c16";
	var military = "c17";
	var philosophy = "c18";
	var mysticism = "c19";
	var deism = "c20";
	var enlightment = "c21";
	var monotheism = "c22";
	var theology = "c23";

	var CIVILIZATION_CARDS_ORDER = new Array("c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","c10","c11","c12","c13","c14","c15","c16","c17","c18","c19","c20","c21","c22","c23");

	var CIVILIZATION_CARDS_DATA = new Object();
	
	CIVILIZATION_CARDS_DATA[pottery] = new Object({name:"Pottery", value:45,group:craft_group});
	CIVILIZATION_CARDS_DATA[clothmaking] = new Object({name:"Cloth Making", value:45,group:craft_group});
	CIVILIZATION_CARDS_DATA[metalworking] = new Object({name:"Metalworking", value:80,group:craft_group});
	CIVILIZATION_CARDS_DATA[agriculture] = new Object({name:"Agriculture", value:110,group:craft_group});
	CIVILIZATION_CARDS_DATA[roadbuilding] = new Object({name:"RoadBuilding", value:140,group:craft_group, required:engineering});
	CIVILIZATION_CARDS_DATA[mining] = new Object({name:"Mining", value:180,group:craft_group, required:engineering});
	CIVILIZATION_CARDS_DATA[engineering] = new Object({name:"Engineering", value:140,group:craft_group+science_group});
	CIVILIZATION_CARDS_DATA[astronomy] = new Object({name:"Astronomy", value:80,group:science_group});
	CIVILIZATION_CARDS_DATA[coinage] = new Object({name:"Coinage", value:110,group:science_group});
	CIVILIZATION_CARDS_DATA[medicine] = new Object({name:"Medicine", value:140,group:science_group});
	CIVILIZATION_CARDS_DATA[mathematics] = new Object({name:"Mathematics", value:230,group:science_group+art_group});
	CIVILIZATION_CARDS_DATA[dramaetpoetry] = new Object({name:"Drama & Poetry", value:60,group:art_group});
	CIVILIZATION_CARDS_DATA[music] = new Object({name:"Music", value:60,group:art_group});
	CIVILIZATION_CARDS_DATA[architecture] = new Object({name:"Architecture", value:120,group:art_group});
	CIVILIZATION_CARDS_DATA[literacy] = new Object({name:"Literacy", value:110,group:civic_group+art_group});
	CIVILIZATION_CARDS_DATA[law] = new Object({name:"Law", value:170,group:civic_group});
	CIVILIZATION_CARDS_DATA[democracy] = new Object({name:"Democracy", value:200,group:civic_group, required:law});
	CIVILIZATION_CARDS_DATA[military] = new Object({name:"Military", value:180,group:civic_group});
	CIVILIZATION_CARDS_DATA[philosophy] = new Object({name:"Philosophy", value:240,group:civic_group, required:law});
	CIVILIZATION_CARDS_DATA[mysticism] = new Object({name:"Mysticism", value:50,group:art_group+religion_group});
	CIVILIZATION_CARDS_DATA[deism] = new Object({name:"Deism", value:80,group:religion_group});
	CIVILIZATION_CARDS_DATA[enlightment] = new Object({name:"Enlightment", value:150,group:religion_group});
	CIVILIZATION_CARDS_DATA[monotheism] = new Object({name:"Monotheism", value:220,group:religion_group, required:enlightment});
	CIVILIZATION_CARDS_DATA[theology] = new Object({name:"Theology", value:250,group:religion_group, required:enlightment});

	var CIVILIZATION_CARDS_DISCOUNTS = new Object();
	
	
	function combine(original) {
		var result = new Array();
		for (var i = 0; i<original.length; i++) {
				result[i]=original[i];
		}
		
		for(i = 1; i<arguments.length-1;i=i+2) {
			var index = $.inArray(arguments[i],CIVILIZATION_CARDS_ORDER);

			result[index] = arguments[i+1];
		}
		return result;
	}
	
	function addDiscountToGroup(groupFilter, cardid, amount) {
		for (var i=0;i<CIVILIZATION_CARDS_ORDER.length;i++) {
			var cid = CIVILIZATION_CARDS_ORDER[i];
			var card = getCivilizationCardInformation(cid);
			if (parseInt(card.group) & parseInt(groupFilter)) {
				var discounts = getCivilizationCardDiscounts(cid);
				if (typeof(discounts)=="undefined") discounts = new Array();
				CIVILIZATION_CARDS_DISCOUNTS[cid]=combine(discounts, cardid, amount);
			}
		}
	}
	

	CIVILIZATION_CARDS_DISCOUNTS[military] = combine({}, metalworking,20);
	CIVILIZATION_CARDS_DISCOUNTS[mathematics] = combine({}, music, 15);
	CIVILIZATION_CARDS_DISCOUNTS[literacy] = combine({}, dramaetpoetry, 15);
	CIVILIZATION_CARDS_DISCOUNTS[democracy] = combine({}, pottery,10, clothmaking, 10, metalworking, 10, agriculture,10, roadbuilding,10, mining, 10, engineering, 10, dramaetpoetry,10, music,10, architecture,10, literacy,25);
	CIVILIZATION_CARDS_DISCOUNTS[law] = combine({}, mathematics, 5, dramaetpoetry, 5, music, 5, architecture, 5, literacy, 25);
	CIVILIZATION_CARDS_DISCOUNTS[philosophy] = combine({}, engineering, 20, astronomy, 20, coinage, 20, medicine, 20, mathematics, 25, music, 20, literacy, 25);
	CIVILIZATION_CARDS_DISCOUNTS[enlightment] = combine({}, mathematics, 10, dramaetpoetry,10, music, 10, architecture, 10, literacy, 10, deism, 10);
	CIVILIZATION_CARDS_DISCOUNTS[theology] = combine({}, engineering,20, astronomy, 20, coinage, 20, medicine, 20, mathematics, 25, deism, 15, enlightment, 15);	
	CIVILIZATION_CARDS_DISCOUNTS[monotheism] = combine({}, pottery, 10, clothmaking,10, metalworking, 10, agriculture, 10, roadbuilding, 10, mining, 10, engineering, 10, deism, 15, enlightment, 15);

	addDiscountToGroup(craft_group, pottery, 10);
	addDiscountToGroup(craft_group, clothmaking, 10);
	addDiscountToGroup(craft_group, metalworking, 10);
	addDiscountToGroup(craft_group, agriculture, 10);
	addDiscountToGroup(craft_group, roadbuilding, 10);
	addDiscountToGroup(craft_group, mining, 10);
	addDiscountToGroup(craft_group, engineering, 10);
	addDiscountToGroup(science_group, engineering, 20);
	addDiscountToGroup(science_group, astronomy, 20);
	addDiscountToGroup(science_group, coinage, 20);
	addDiscountToGroup(science_group, coinage, 20);
	addDiscountToGroup(science_group, medicine, 20);
	addDiscountToGroup(science_group, mathematics, 20);
	addDiscountToGroup(art_group, mathematics, 5);
	addDiscountToGroup(art_group, dramaetpoetry, 5);
	addDiscountToGroup(art_group, music, 5);
	addDiscountToGroup(art_group, architecture, 5);
	addDiscountToGroup(art_group, literacy, 5);
	addDiscountToGroup(art_group, mysticism, 5);
	addDiscountToGroup(religion_group, mysticism, 15);
		
	
	var CIVILIZATIONS_ORDER = new Array("africa","iberia","italy","illyria","thrace","crete","asia","assyria","babylon","egypt");
	
	var CIVILIZATIONS_DATA = new Object();
	CIVILIZATIONS_DATA['africa']=new Object({name:"Africa"});
	CIVILIZATIONS_DATA['iberia']=new Object({name:"Iberia"});
	CIVILIZATIONS_DATA['italy']=new Object({name:"Italy"});
	CIVILIZATIONS_DATA['illyria']=new Object({name:"Illyria"});
	CIVILIZATIONS_DATA['thrace']=new Object({name:"Thrace"});
	CIVILIZATIONS_DATA['crete']=new Object({name:"Crete"});
	CIVILIZATIONS_DATA['asia']=new Object({name:"Asia"});
	CIVILIZATIONS_DATA['assyria']=new Object({name:"Assyria"});
	CIVILIZATIONS_DATA['babylon']=new Object({name:"Babylon"});
	CIVILIZATIONS_DATA['egypt']=new Object({name:"Egypt"});

	function getCivilizationCardDiscounts(cardid) {
		return CIVILIZATION_CARDS_DISCOUNTS[cardid];
	}
	
	function getCivilizationCardInformation(cardid) {
		return CIVILIZATION_CARDS_DATA[cardid];
	}

	function getCivilizationInformation(civid) {
		return CIVILIZATIONS_DATA[civid];
	}
  	